//
//  CMDetailFoodView.m
//  项目三
//
//  Created by rimi1 on 2016/11/26.
//  Copyright © 2016年 Wangxingqian. All rights reserved.
//

#import "CMDetailFoodView.h"

static NSInteger spacing_ = 20;

@implementation CMDetailFoodView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.back];
        [self addSubview:self.collect];
    }
    return self;
}

- (void)respondsToButton:(UIButton *)sender {
    if (self.buttonBlock) {
        self.buttonBlock(sender);
    }
}

#pragma mark - get

- (UIButton *)back {
    
    if (!_back) {
        
        _back = [[UIButton alloc] initWithFrame:CGRectMake(WXQAdaptionWidth(spacing_/2), 0, self.bounds.size.height, self.bounds.size.height)];
        _back.tag = 100;
        [_back addTarget:self action:@selector(respondsToButton:) forControlEvents:UIControlEventTouchUpInside];
        [_back setImage:[UIImage imageNamed:@"黑色返回"] forState:UIControlStateNormal];
        
    }
    return _back;
}

- (UIButton *)collect {
    
    if (!_collect) {
        
        _collect = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.back.frame) + WXQAdaptionWidth(spacing_/2), 0, self.bounds.size.height, self.bounds.size.height)];
        _collect.tag = 101;
        [_collect addTarget:self action:@selector(respondsToButton:) forControlEvents:UIControlEventTouchUpInside];
        [_collect setImage:[UIImage imageNamed:@"未收藏"] forState:UIControlStateNormal];
        [_collect setImage:[UIImage imageNamed:@"已收藏"] forState:UIControlStateSelected];
        
    }
    return _collect;
}

@end












